package com.inspinia.auth.rpc.api;

import com.inspinia.upms.common.model.resource.UpmsResource;
import com.inspinia.upms.common.model.user.UpmsUser;
import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.subject.PrincipalCollection;

import java.util.List;
/**
 * AuthService class
 *
 * @author veblen
 * @date 2018/10/9
 */
public interface AuthService {
    /**
     * 验证用户信息
     * @param username
     * @param pwd
     * @return
     */
    UpmsUser findUser(String username, String pwd);

    /**
     * 获取拥有的权限
     * @param userName
     * @param appName
     * @return
     */
    SimpleAuthorizationInfo getAuthorizationInfo(String userName,String appName);

    /**
     * 根据id获取用户
     * @param userId
     * @return
     */
    UpmsUser findById(Long userId);

    /**
     * 按照用户名查找
     * @param userName
     * @return UpmsUser
     */
    UpmsUser findByUserName(String userName);
    /**
     * 查找用户可以拥有的资源
     *
     * @param userId 用户id
     * @return
     */
    List<UpmsResource> findResourcesByUser(Long userId);

    /**
     * 根据shiro对象获取用户
     * @param principals
     * @return
     */
    UpmsUser getUserByPrincipal(PrincipalCollection principals);
}
